package qldc.pm.tienan.service.impl;

import java.util.Date;

import qldc.pm.tienan.NoSuchPhieuThongTinVeNguoiCoTienAnException;
import qldc.pm.tienan.model.PhieuThongTinVeNguoiCoTienAn;
import qldc.pm.tienan.model.impl.PhieuThongTinVeNguoiCoTienAnImpl;
import qldc.pm.tienan.service.base.PhieuThongTinVeNguoiCoTienAnLocalServiceBaseImpl;

import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;

/**
 * The implementation of the phieu thong tin ve nguoi co tien an local service.
 *
 * <p>
 * All custom service methods should be put in this class. Whenever methods are
 * added, rerun ServiceBuilder to copy their definitions into the
 * {@link qldc.pm.tienan.service.PhieuThongTinVeNguoiCoTienAnLocalService}
 * interface.
 *
 * <p>
 * This is a local service. Methods of this service will not have security
 * checks based on the propagated JAAS credentials because this service can only
 * be accessed from within the same VM.
 * </p>
 *
 * @author Brian Wing Shun Chan
 * @see qldc.pm.tienan.service.base.PhieuThongTinVeNguoiCoTienAnLocalServiceBaseImpl
 * @see qldc.pm.tienan.service.PhieuThongTinVeNguoiCoTienAnLocalServiceUtil
 */
public class PhieuThongTinVeNguoiCoTienAnLocalServiceImpl extends
		PhieuThongTinVeNguoiCoTienAnLocalServiceBaseImpl {
	public PhieuThongTinVeNguoiCoTienAn addPhieu(long tienAnId, long userId,
			String userName, String maSoHoSoTienAnTuToaAn,
			String nguoiTrichLuc, String thamPhan, String soDinhDanhCaNhan,
			String chuThich, String hoTenVoHoacChong, String hoTenCha,
			String hoTenMe, long noiThuongTruTinhId,
			long noiThuongTruQuanHuyenId, long noiThuongTruPhuongXaId,
			String noiThuongTruDiaChi, long noiTamTruTinhId,
			long noiTamTruQuanHuyenId, long noiTamTruPhuongXaId,
			String noiTamTruDiaChi) throws SystemException {
		long PhieuThongTinVeNguoiCoTienAnId = counterLocalService.increment(PhieuThongTinVeNguoiCoTienAn.class.getName());
		PhieuThongTinVeNguoiCoTienAn phieuThongTin =createPhieuThongTinVeNguoiCoTienAn(PhieuThongTinVeNguoiCoTienAnId);

		phieuThongTin.setUserId(userId);
		phieuThongTin.setUserName(userName);
		phieuThongTin.setCreateDate(new Date());
		phieuThongTin.setHoTenCha(hoTenCha);
		phieuThongTin.setHoTenMe(hoTenMe);
		phieuThongTin.setHoTenVoHoacChong(hoTenVoHoacChong);
		phieuThongTin.setTienAnId(tienAnId);
		phieuThongTin.setMaSoHoSoTienAnTuToaAn(maSoHoSoTienAnTuToaAn);
		phieuThongTin.setNguoiTrichLuc(nguoiTrichLuc);
		phieuThongTin.setThamPhan(thamPhan);
		phieuThongTin.setSoDinhDanhCaNhan(soDinhDanhCaNhan);
		phieuThongTin.setChuThich(chuThich);

		phieuThongTin.setNoiTamTruTinhId(noiTamTruTinhId);
		phieuThongTin.setNoiTamTruQuanHuyenId(noiTamTruQuanHuyenId);
		phieuThongTin.setNoiTamTruPhuongXaId(noiTamTruPhuongXaId);
		phieuThongTin.setNoiTamTruDiaChi(noiTamTruDiaChi);
		phieuThongTin.setNoiThuongTruTinhId(noiThuongTruTinhId);
		phieuThongTin.setNoiThuongTruQuanHuyenId(noiThuongTruQuanHuyenId);
		phieuThongTin.setNoiThuongTruPhuongXaId(noiThuongTruPhuongXaId);
		phieuThongTin.setNoiThuongTruDiaChi(noiThuongTruDiaChi);
		phieuThongTin = addPhieuThongTinVeNguoiCoTienAn(phieuThongTin);

		return phieuThongTin;
	}

	public PhieuThongTinVeNguoiCoTienAn updatePhieu(
			long phieuThongTinVeNguoiCoTienAnId, long tienAnId, long userId,
			String userName, String maSoHoSoTienAnTuToaAn,
			String nguoiTrichLuc, String thamPhan, String soDinhDanhCaNhan,
			String chuThich, String hoTenVoHoacChong,
			String hoTenCha, String hoTenMe, long noiThuongTruTinhId,
			long noiThuongTruQuanHuyenId, long noiThuongTruPhuongXaId,
			String noiThuongTruDiaChi, long noiTamTruTinhId,
			long noiTamTruQuanHuyenId, long noiTamTruPhuongXaId,
			String noiTamTruDiaChi) throws SystemException, PortalException {
		PhieuThongTinVeNguoiCoTienAn phieuThongTin = getPhieuThongTinVeNguoiCoTienAn(phieuThongTinVeNguoiCoTienAnId);

		phieuThongTin.setUserId(userId);
		phieuThongTin.setUserName(userName);
		phieuThongTin.setModifiedDate(new Date());

		phieuThongTin.setTienAnId(tienAnId);
		phieuThongTin.setMaSoHoSoTienAnTuToaAn(maSoHoSoTienAnTuToaAn);
		phieuThongTin.setHoTenCha(hoTenCha);
		phieuThongTin.setHoTenMe(hoTenMe);
		phieuThongTin.setHoTenVoHoacChong(hoTenVoHoacChong);
		phieuThongTin.setTienAnId(tienAnId);
		phieuThongTin.setNguoiTrichLuc(nguoiTrichLuc);
		phieuThongTin.setThamPhan(thamPhan);
		phieuThongTin.setSoDinhDanhCaNhan(soDinhDanhCaNhan);
		phieuThongTin.setChuThich(chuThich);
		phieuThongTin.setNoiTamTruTinhId(noiTamTruTinhId);
		phieuThongTin.setNoiTamTruQuanHuyenId(noiTamTruQuanHuyenId);
		phieuThongTin.setNoiTamTruPhuongXaId(noiTamTruPhuongXaId);
		phieuThongTin.setNoiTamTruDiaChi(noiTamTruDiaChi);
		phieuThongTin.setNoiThuongTruTinhId(noiThuongTruTinhId);
		phieuThongTin.setNoiThuongTruQuanHuyenId(noiThuongTruQuanHuyenId);
		phieuThongTin.setNoiThuongTruPhuongXaId(noiThuongTruPhuongXaId);
		phieuThongTin.setNoiThuongTruDiaChi(noiThuongTruDiaChi);
		
		phieuThongTin = updatePhieuThongTinVeNguoiCoTienAn(phieuThongTin);

		return phieuThongTin;
	}

	public PhieuThongTinVeNguoiCoTienAn findByMaHoSoToaAn(
			String maSoHoSoTienAnTuToaAn) {
		PhieuThongTinVeNguoiCoTienAn phieuThongTinVeNguoiCoTienAn = null;

		try {
			phieuThongTinVeNguoiCoTienAn = phieuThongTinVeNguoiCoTienAnPersistence
					.findByMaSoHoSoTienAnTuToaAn(maSoHoSoTienAnTuToaAn);
		} catch (NoSuchPhieuThongTinVeNguoiCoTienAnException e) {
		} catch (SystemException e) {
		}

		return phieuThongTinVeNguoiCoTienAn;
	}

	public PhieuThongTinVeNguoiCoTienAn findByTienAnId(long tienAnId) {
		PhieuThongTinVeNguoiCoTienAn phieuThongTinVeNguoiCoTienAn = null;

		try {
			phieuThongTinVeNguoiCoTienAn = phieuThongTinVeNguoiCoTienAnPersistence
					.findByTienAnId(tienAnId);
		} catch (NoSuchPhieuThongTinVeNguoiCoTienAnException e) {
		} catch (SystemException e) {
		}

		return phieuThongTinVeNguoiCoTienAn;
	}
}
